<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>手续费比例配置</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div id="pageInTab" class="pageInTab">
	<form id="formSet1">
	    <div class="fieldset1 tabel_col clearFix">
		    <div class="fieldBox col_100">
		        <div class="sqPanel">
		            <div class="sqPanel_head inL">
		                <div class="btnsBox inLC">
		                    <span id="addBtn" class="sq-button sq-button-round">添加</span>
		                    <span id="delBtn" class="sq-button sq-button-round">删除</span>
		                </div>
		                    <span>手续费比例配置</span>
		            </div>
		            <div class="sqPanel_body">
		                <div id="ligergrid_reb" class="sq-grid"></div>
		            </div>
		        </div>
		    </div>
		</div>
		<div class="fieldset1 clearFix">
			<div class="btnsBox">
				<span id="saveBtn1" class="sq-button sq-button-round">保存</span>
				<input name=prpsCfgId id="prpsCfgId" type="hidden" value="${prpsCfgId }">
			</div>
		</div>
	</form>
</div>
</div>

<script type="text/javascript">
var rebGrid;//相关费用信息
var loadedTabs=[];
var isDetail = '${isDetail}';

$(function(){
	$('#formSet1').ligerForm({
        validate : true
	});
	$("#saveBtn1").click(function(event) {
	    var form = liger.get("formSet1");
	    if (!form.valid()) {
	    	$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
            return false;
        }
	    var data = form.getData();
        data["rebInfo"] = JSON.stringify(rebGrid.getData());
        data["prpsCfgId"] = $("#prpsCfgId").val();
        
        var url = '<%=path%>/project/prjQuatPrpsReb/batchAdd.do';
        
        var wait_dialog;
	    $.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: url,
			beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
			success:function(msg){
				 wait_dialog.close();
				 if(msg.success == 1){
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					 rebGrid.reload();
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	});

    //是否
	var yesOrNoCdListJSON = [];
    <c:if test="${not empty yesOrNoCdListJSON}"> yesOrNoCdListJSON = ${yesOrNoCdListJSON}; </c:if>
	rebGrid = $("#ligergrid_reb").ligerGrid({
        url: '<%=path%>/project/prjQuatPrpsReb/initList.do?pctTypCd=2&prpsCfgId=${prpsCfgId}',
        method: 'get',
        columns: [
            {display: '是否新车', name: 'isNew', minWidth: 80,
            	editor: {
                    type: 'select',
                    data: yesOrNoCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'isNew',
                textField: 'isNewNm',
                render: function (item) {
                    return item.isNewNm;
                }
            },
            {display: '租赁期数', name: 'lsPd', minWidth: 80, type: 'text',align: 'right',
            	editor: {type: 'digits'}
            },
            {display: '手续费比例（%）', name: 'lsRebPct', minWidth: 80,type: 'text',align: 'right',
	            editor: {type: 'number',precision: 0}
            },
            {display: '比例类型', name: 'pctTypCd', width: 0, editor: {readonly: true},hide:true },
        ],
        onBeforeSubmitEdit: function (e) {
        },
        onBeforeEdit: function (e) {
        	if(isDetail==1){
        		e.column.editor.readonly = true;
        	}
        },
        usePager: false,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        height: 300,
        heightDiff: -2,
        enabledEdit: true,
        isScroll: false,
        checkbox: true,
        rownumbers: true,
        allowUnSelectRow: true,
        alternatingRow: false
    });
	$("#addBtn").click(function (event) {
        rebGrid.addRow({
        	isNew: '',
        	lsPd: '',
        	lsRebPct: '',
        	pctTypCd:'2'
        });
    });
	$("#delBtn").click(function (event) {
        var selectedRows = rebGrid.getSelectedRows();
        if(selectedRows.length == 0){
			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW , SQ_type: "warning" });
			return;
		}
        rebGrid.deleteSelectedRow();
    });
});

</script>



</body>
</html>
